package psc.model.base.cliente;

import java.util.Collection;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import psc.model.base.transacao.Liberacao;

@Entity
@Table
public class Emprestimo {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int id;

	@ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.ALL })
	@JoinColumn(name = "conta_id", nullable = false)
	private Conta conta;

	@Column(name = "qtd_parcelas", nullable = false)
	private int qtdParcela;

	@Column(name = "valor", nullable = false)
	private double valor;

	@Column(name = "taxas_juros", nullable = false)
	private long taxaJuros;

	@OneToMany(mappedBy = "emprestimo", fetch = FetchType.LAZY, cascade = { CascadeType.ALL })
	private Collection<Liberacao> liberacoes;

	@OneToMany(mappedBy = "emprestimo", fetch = FetchType.LAZY, cascade = { CascadeType.ALL })
	private Collection<Parcela> parcelas;

	@Column(name = "dataCadastro", nullable = false)
	@Temporal(TemporalType.DATE)
	private Date dataCadastro;

	public int getQtdParcela() {
		return qtdParcela;
	}

	public void setQtdParcela(int qtdParcela) {
		this.qtdParcela = qtdParcela;
	}

	public Collection<Parcela> getParcelas() {
		return parcelas;
	}

	public void setParcelas(Collection<Parcela> parcelas) {
		this.parcelas = parcelas;
	}

	public Date getDataCadastro() {
		return dataCadastro;
	}

	public void setDataCadastro(Date dataCadastro) {
		this.dataCadastro = dataCadastro;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Conta getConta() {
		return conta;
	}

	public void setConta(Conta conta) {
		this.conta = conta;
	}

	public double getValor() {
		return valor;
	}

	public void setValor(double valor) {
		this.valor = valor;
	}

	public long getTaxaJuros() {
		return taxaJuros;
	}

	public void setTaxaJuros(long taxaJuros) {
		this.taxaJuros = taxaJuros;
	}

	public Collection<Liberacao> getLiberacaos() {
		return liberacoes;
	}

	public void setLiberacaos(Collection<Liberacao> liberacoes) {
		this.liberacoes = liberacoes;
	}

}
